Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(FPI): Make storage maps usable by querying the node #645

Merged
merged 5 commits into from
Jan 15, 2025

Conversation

igamigo
Copy link
Collaborator

@igamigo igamigo commented Dec 22, 2024

Implements changes following up 0xPolygonMiden/miden-node#598 in order to allow using storage maps on FPI.
This was a feature requested by pioneers.

@igamigo igamigo marked this pull request as ready for review December 27, 2024 20:41
@igamigo igamigo changed the title feat: Make storage maps usable on FPI feat(FPI): Make storage maps usable by querying the node Dec 30, 2024
Copy link
Collaborator

@tomyrd tomyrd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, left some minor comments/questions.

crates/rust-client/src/rpc/domain/accounts.rs Show resolved Hide resolved
crates/rust-client/src/rpc/domain/accounts.rs Show resolved Hide resolved
///
/// At execution, the client queries the node and retrieves account-related data, based on
/// what's defined in `foreign_accounts`
pub fn with_foreign_accounts(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could end up with duplicate accounts when using with_foreign_accounts/with_public_foreign_accounts/with_private_foreign_accounts. Maybe we could do a duplicate check when inserting or store them in a BTreeMap/Set. Plus, do we need all 3 methods? Maybe we could have just the first one, the creation of the ForeignAccount items would need to be done by the caller.

Copy link
Collaborator Author

@igamigo igamigo Jan 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, agree that it complicates things a bit. I unified the API into a single with_foreign_accounts call. I think the advantage of keeping the other 2 instead of this one is that the user does not necessarily need to know about nor instantiate a ForeignAccount enum variant, so maybe that is a nicer approach.
I also changed the builder to use a map (AccountId -> ForeignAccount) to handle duplicates.

@igamigo igamigo changed the base branch from next to igamigo-ci January 10, 2025 18:49
Base automatically changed from igamigo-ci to next January 10, 2025 19:02
@igamigo igamigo requested a review from bobbinth January 13, 2025 19:56
@igamigo
Copy link
Collaborator Author

igamigo commented Jan 15, 2025

Talked to @bobbinth. Merging this for now, in order to make migration to the latest revisions of miden-base's and miden-node's next. I can address any potential comment in a future PR.

@igamigo igamigo merged commit a15694e into next Jan 15, 2025
15 checks passed
@igamigo igamigo deleted the igamigo-fpi-maps branch January 15, 2025 15:21
}

let headers = if include_headers && account_id.is_public() {
// Because we set `include_headers` to true, for any public account we requeted we
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Because we set `include_headers` to true, for any public account we requeted we
// Because we set `include_headers` to true, for any public account we requested we

/// At execution, the client queries the node and retrieves the state and current code for
/// these accounts, and injects them as advice inputs.
/// Specifies one or more foreign accounts (public or private) that contain data
/// utilized by the transaction.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// utilized by the transaction.
/// used by the transaction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants